package com.bainuo.doctor.common.image_support.filedownload;

import com.bainuo.doctor.common.model.FileDownLoadTask;

import java.util.HashMap;
import java.util.Map;

public abstract class IFileDownload {

	protected FileDownloadListener _listener;
	//最大下载数
	protected int _downLoadTaskMaxCount = 1;

	//总任务
	protected Map<String,FileDownLoadTask> _taskMap = new HashMap();
	//正在下载的任务
	protected Map<String,FileDownLoadTask> _downloadQueue = new HashMap();

	//开始下载
	protected abstract void startDownload(FileDownLoadTask tid);

//	public void resumeTask(String tid);

	//暂停任务
	public abstract void pauseTask(String tid);

	//获取任务进度
	public abstract int getTaskProgress(String tid);

	//获取任务进度
	public abstract FileDownLoadTask getTask(String tid);

	//获取任务状态
	public abstract FileDownLoadTask.TASK_STATUS getTaskStatus(String tid);

	//取消任务
	public abstract void cancelTask(String tid);

	protected FileDownloadListener getDownloadListener() {
		return _listener;
	}

	protected void setDownloadListener(FileDownloadListener aListener) {
		_listener = aListener;
	}

	public int getDownLoadTaskMaxCount() {
		return _downLoadTaskMaxCount;
	}

	public void setDownLoadTaskMaxCount(int aDownLoadTaskMaxCount) {
		_downLoadTaskMaxCount = Math.max(1,aDownLoadTaskMaxCount);
	}

	public abstract boolean canDownload(FileDownLoadTask task);

//	public abstract String getFilePath(String taskId);
}